package com.wxd.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wxd.entity.Student;
import com.wxd.service.StudentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wxd
 * @since 2022-03-08
 */
@RestController
@RequestMapping("/student")
public class StudentController {
    @Resource private StudentService ss;
    @GetMapping("/selectAll")
    public List<Student> selectAll(){
        return ss.list();
    }
    @GetMapping("/selectByCid")
    public List<Student> selectByCid(int cid){
        QueryWrapper<Student> wrapper = new QueryWrapper<>();
        wrapper.eq("cid",cid);
        return ss.list(wrapper);
    }
    @PostMapping("/add")
    public void add(@RequestBody Student stu){
        ss.save(stu);
    }
    @DeleteMapping("/deleteById/{id}")
    public void deleteById(@PathVariable("id") int id){
        ss.removeById(id);
    }
}

